package com.xiaoq.distribution.repository;

import com.mongodb.DuplicateKeyException;
import com.xiaoq.distribution.entity.TicketOrderItemEntity;
import com.xiaoq.vo.PagingVo;

import java.util.List;

/**
 * Created by chenjh on 2018/5/31.
 */
public interface ITicketOrderItemRepository {

    boolean save(TicketOrderItemEntity ticketOrderItemEntity) ;

    boolean updateById(TicketOrderItemEntity ticketOrderItemEntity);

    boolean updateByOrderId(TicketOrderItemEntity ticketOrderItemEntity);


    /**
     * 已下单，但未结算的订单
     * @param shopOrderId 订单号
     * @param distributorId 分销号
     * @param ticketId 票id
     * @param minCreateTime 下单时间
     * @param maxCreateTime 下单时间
     * @param payState 支付状态
     * @return
     */
    List<TicketOrderItemEntity> getOrderItemList(String shopOrderId,
                                                 String distributorId,
                                                 String ticketId,
                                                 Long minCreateTime,
                                                 Long maxCreateTime,
                                                 Integer payState);

    /**
     * 已使用，但未结算的  的门票信息
     * @param shopOrderId
     * @param distributorId
     * @param ticketId
     * @param minUseTime
     * @param maxUseTime
     * @param payState
     * @return
     */
    List<TicketOrderItemEntity> getUseOrderItemList(String shopOrderId,
                                                 String distributorId,
                                                 String ticketId,
                                                 Long minUseTime,
                                                 Long maxUseTime,
                                                 Integer payState);

    /**
     *  已下单结算了， 但退款未结算 的订单
     * @param shopOrderId
     * @param distributorId
     * @param ticketId
     * @param minRefundTime
     * @param maxRefundTime
     * @param payState
     * @return
     */
    List<TicketOrderItemEntity> getRefundOrderItemList(String shopOrderId,
                                                 String distributorId,
                                                 String ticketId,
                                                 Long minRefundTime,
                                                 Long maxRefundTime,
                                                 Integer payState);

    TicketOrderItemEntity getById(String id);

    List<TicketOrderItemEntity> getListByShopOrderId(String shopOrderId);

    TicketOrderItemEntity getByTicketCode(String ticketCode);

    long getUseOrderItemCountByOrderId(String shopOrderId);

    /**
     * @param shopId 景区id
     * @param orderIdOrItemIdOrTicketCode 可能是 订单号，订单明细号，电子票号
     * @param useBeginTime
     * @param useEndTime
     * @param pagingVo
     * @return
     */
    List<TicketOrderItemEntity> getList4SettleRecord(String shopId, String orderIdOrItemIdOrTicketCode, Long useBeginTime, Long useEndTime, PagingVo pagingVo);

    /**
     *  查询分页
     * @param shopId
     * @param orderIdOrItemIdOrTicketCode
     * @param useBeginTime
     * @param useEndTime
     * @return
     */
    long getCount4SettleRecord(String shopId,String orderIdOrItemIdOrTicketCode, Long useBeginTime, Long useEndTime);
}
